import Vue from 'vue';
import Vuex from 'vuex'; //引入 vuex
 
Vue.use(Vuex); //使用 vuex
 
export default new Vuex.Store({
  state: {
    // 初始化状态
    isPet:null,//已领红包
    money:false,//领红包弹框-隐藏
    coupon:false,//领券弹框-隐藏
    isLogin:false,
    ownid:0,
  },
  mutations: {
    // 处理状态
    onmoney(state,n) {
      if(state.isPet!=null){
        state.money = !state.isPet&&n.money;
      }else{
        state.money = false;
      }
    },
    onpet(state,n){
      state.isPet = n.isPet;
    },
    oncoupon(state,n){
      if(state.isPet!=null){
        state.coupon = state.isPet&&n.coupon;
      }else{
        state.coupon = false;
      }
    },
    onlogin(state,n){
      if(state.isLogin!=null){
        state.isLogin = n.isLogin;
      }else{
        state.isLogin = false;
      }
    },
    onownid(state,n){
      if(state.ownid!=null){
        state.ownid = n.ownid;
      }else{
        state.ownid = 0;
      }
    }
  }
})